package com.hh.test.design.filter;

import java.util.ArrayList;
import java.util.List;

public class SexFilter implements Filter {

	private String sex;

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public SexFilter(String sex) {
		super();
		this.sex = sex;
	}

	@Override
	public List<Person> filter(List<Person> persons) {
		List<Person> l = new ArrayList<>();
		for (Person p : persons) {
			if (p.getSex().equals(this.getSex())) {
				l.add(p);
			}
		}
		return l;
	}

}
